<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>自习室预订</title>
    <link rel="stylesheet" href="/static/jquery-weui/lib/weui.min.css">
    <link rel="stylesheet" href="/static/jquery-weui/css/jquery-weui.min.css">
    <style>
        .page-title {
            text-align: center;
            font-size: 34px;
            color: #3cc51f;
            font-weight: 400;
            margin: 0 15%;
        }
    </style>
</head>
<body>

<header style="padding: 35px 0;">
    <h1 class="page-title">登录</h1>
</header>

<div class="weui-cells__title">用户名/手机号</div>
<div class="weui-cells">
    <div class="weui-cell">
        <div class="weui-cell__bd">
            <input id="username" class="weui-input" type="text" placeholder="请输入用户名">
        </div>
    </div>
</div>
<div class="weui-cells__title">密码</div>
<div class="weui-cells">
    <div class="weui-cell">
        <div class="weui-cell__bd">
            <input id="password" class="weui-input" type="password" placeholder="请输入密码">
        </div>
    </div>
</div>
<div class="weui-btn-area">
    <a href="javascript: doLogin();" class="weui-btn weui-btn_plain-primary">登录</a>
</div>
<div class="weui-btn-area">
    <a href="/index" class="weui-btn weui-btn_plain-primary">返回</a>
</div>


<script src="/static/jquery-3.3.1.min.js"></script>
<script src="/static/jquery-weui/js/jquery-weui.min.js"></script>
<script>
    function doLogin() {

            var loginData = {
                username:$('#username').val(),
                password:$('#password').val(),
                RemberMe:1
            };

            $.ajax({
                url: '/api/user/login',
                method: 'POST',
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(loginData),
                success: function () {
                    window.location.href = '/';
                },
                error: function () {
                    $.alert('用户名或密码错误！', '错误信息');
                }
            });

    }
</script>
</body>
</html>